package com.cheung.leetcode.normal;

import java.util.Arrays;

public class LC27 {

    public static int removeElement(int[] nums, int val) {
        if (nums == null) {
            return 0;
        }

        int slow = 0;

        for (int high = 0; high < nums.length; high++) {
            if (nums[high] != val) {
                nums[slow++] = nums[high];
            }
        }

        return slow;
    }


    public static void main(String[] args) {
        int[] nums = {0,1,2,2,3,0,4,2};
        int val = 3;
        int i = removeElement(nums, 2);
        System.out.println(i);
        System.out.println(Arrays.toString(nums));
    }
}
